package svg

import (
	"gosvg/dom"
)

type GElement struct {
	*dom.Element
}

//G creates a GElement, used to group other SVG elements
func G() *GElement {
	return &GElement{Element: dom.MakeElementNs("g", SvgNamespace)}
}

//AddTransform adds an arbitrary transform string
func (g *GElement) AddTransform(s string) {
	g.AddToAttribute("transform", s)
}

//Scale scales the group by n
func (g *GElement) Scale(n float64) {
	g.AddTransform("scale(" + fVal(n) + ")")	
}

//Scale scales the group by x along the x-axis and y along the y-axis
func (g *GElement) ScaleXY(x, y float64) {
	g.AddTransform(`scale(` + coords(x, y) + `)`)
}


func (g *GElement) SkewX(n float64) {
	g.AddTransform("skewX(" + fVal(n) + ")")
}

func (g *GElement) SkewY(n float64) {
	g.AddTransform("skewY(" + fVal(n) + ")")
}

//Rotate rotates the group by r
func (g *GElement) Rotate(r float64) {
	g.AddTransform("skewY(" + fVal(r) + ")")
}

//Translate translates the group by (x,y)
func (g *GElement) Translate(x, y float64) {
	g.AddTransform(`translate(` + coords(x, y) + `)`)
}

func (g *GElement) Matrix(m1, m2, m3, m4, m5, m6 float64) {
	g.AddTransform(`matrix(` + coords(m1, m2) + `,` + coords(m3, m4) + `,` + coords(m5, m6))
}
